package jmine.tec.test.matchers;

import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;

import bancosys.tec.exception.LocalizedMessageHolder;

/**
 * @author lundberg
 */
public class MessageHolderMatcher extends TypeSafeMatcher<LocalizedMessageHolder> {

    private LocalizedMessageHolder expected;

    /**
     * @param expected expected
     * @return MessageHolderMatcher
     */
    public static MessageHolderMatcher message(LocalizedMessageHolder expected) {
        return new MessageHolderMatcher(expected);
    }

    /**
     * Constructor
     * 
     * @param expected expected
     */
    public MessageHolderMatcher(LocalizedMessageHolder expected) {
        super();
        this.expected = expected;
    }

    /**
     * {@inheritDoc}
     */
    public void describeTo(Description description) {
        description.appendText(this.expected.getMessage());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean matchesSafely(LocalizedMessageHolder actual) {
        return this.expected.getMessage().equals(actual.getMessage());
    }
}
